Repository navigation
Complete Plutus V4 support and remove Conway hardcodes - #1452
Conversation
d8466db to
8ef9c2d
Compare
8ef9c2d to
d193e61
Compare
01979c5 to
389f27d
Compare
389f27d to
d349d1d
Compare
d349d1d to
a76317a
Compare
a76317a to
c1fa806
Compare
c1fa806 to
1740c08
Compare
1740c08 to
81df3c9
Compare
81df3c9 to
642d7a0
Compare
5411875 to
f85ccf6
Compare
There was a problem hiding this comment.
🟢 Approval recommended
Static review found no blocking defects; the remaining diagnostic refinement is non-blocking, and tests were not executed.
1 open finding
What changed in this PR
Completes CLI-side Plutus V4 support following #1453 and centralizes era selection without changing the current mainnet default.
Changes:
- Shares script hashing across hash, policy ID, and address commands.
- Rejects unsupported reference-script languages and accepts all known
CARDANO_ERAnames. - Adds V4 regression tests, fixtures, and changelog entries.
| File | Description |
|---|---|
| cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/Build.hs | Tests V4 policy IDs. |
| cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Address/Build.hs | Tests V4 payment and stake addresses. |
| cardano-cli/test/cardano-cli-golden/Test/Golden/Hash/Hash.hs | Tests V4 script hashing. |
| cardano-cli/test/cardano-cli-golden/Test/Golden/Dijkstra/Transaction/BuildRaw.hs | Tests all six V4 witness purposes. |
| cardano-cli/test/cardano-cli-golden/Test/Golden/Conway/Transaction/ReferenceScript.hs | Tests unsupported reference-script rejection. |
| cardano-cli/test/cardano-cli-golden/files/input/dijkstra/plutus/v4-always-succeeds.plutus | Adds V4 script fixture. |
| cardano-cli/test/cardano-cli-golden/files/golden/dijkstra/transaction/build-raw-plutus-v4-script-witnesses.out | Records V4 transaction output. |
| cardano-cli/test/cardano-cli-golden/files/golden/dijkstra/plutus/v4-always-succeeds.hash | Records expected script hash. |
| cardano-cli/test/cardano-cli-golden/files/golden/dijkstra/address/build-stake-script-v4.addr | Records V4 stake-script address. |
| cardano-cli/test/cardano-cli-golden/files/golden/dijkstra/address/build-payment-script-v4.addr | Records V4 payment-script address. |
| cardano-cli/test/cardano-cli-golden/files/golden/conway/transaction/build-raw-reference-script-unsupported-language.out | Records rejection diagnostic. |
| cardano-cli/src/Cardano/CLI/Read.hs | Adds newest-era script-hash reader. |
| cardano-cli/src/Cardano/CLI/Option.hs | Uses mainnet alias for top-level commands. |
| cardano-cli/src/Cardano/CLI/EraIndependent/Hash/Run.hs | Uses shared hash reader. |
| cardano-cli/src/Cardano/CLI/EraIndependent/Address/Run.hs | Uses shared reader for script credentials. |
| cardano-cli/src/Cardano/CLI/EraBased/Transaction/Run.hs | Uses shared reader for policy IDs. |
| cardano-cli/src/Cardano/CLI/EraBased/Option.hs | Defines mainnet alias and derives help text. |
| cardano-cli/src/Cardano/CLI/Environment.hs | Parses known eras case-insensitively. |
| cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs | Rejects unsupported reference scripts. |
| cardano-cli/cardano-cli.cabal | Registers new test modules. |
| .changes/reference-script-unsupported-language.yml | Documents reference-script rejection. |
| .changes/plutus-v4-script-witnesses.yml | Documents V4 regression coverage. |
| .changes/plutus-v4-script-readers.yml | Documents expanded script-reader support. |
| .changes/cardano_era_all_eras.yml | Documents environment-era parsing. |
| .changes/20261015_120100_cardano-cli_mateusz.galazyn_read-any-script-hash.yml | Documents shared reader and era alias. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| scriptInEra <- | ||
| fromMaybeCli | ||
| (TxOutputReferenceScriptLanguageNotSupportedInEra script (anyCardanoEra $ toCardanoEra sbe)) | ||
| $ toScriptInEra sbe script |
There was a problem hiding this comment.
The rejection itself is correct: a native script with a guard is only valid from Dijkstra onwards, so a Conway output cannot carry it, and the transaction is rejected at build time.
The message names the script language because cardano-api's toScriptInEra only returns Nothing, and its simpleScriptHasGuard check is not exported.
A guard-specific message is better added in cardano-api than by copying that traversal into cardano-cli, so I'm leaving it as is here.
f85ccf6 to
b1a7451
Compare
b149a30 to
e972489
Compare
A transaction output whose reference script is in a Plutus language the era does not support used to lose the script silently. Fail with cardano-api's `TxOutputReferenceScriptLanguageNotSupportedInEra` error instead, using the same `toScriptInEra` check as cardano-api's `validateTxOutsReferenceScripts`, which is not exported. Read script files for `hash script`, `transaction policyid` and `address build` `--payment-script-file` and `--stake-script-file` in cardano-api's newest era, so they accept Plutus V4 scripts instead of failing with "not supported in the Conway era". Add Plutus V4 golden tests: - a V4 script file as a direct witness for all six script purposes in `dijkstra transaction build-raw`, checked with `debug transaction view` - hashing a V4 script with `hash script` - `transaction policyid` and `address build` with a V4 script - the error for a V4 reference script in a Conway transaction Parse `CARDANO_ERA` by reusing cardano-api's era enumeration and rendering instead of a hand-written string table, so newer eras such as dijkstra are accepted. An unknown value still stops the command, now with an error that lists the valid eras. The latest command group and the top-level node and query command groups follow the era running on mainnet. A MainnetEra alias names that choice, so the hard fork changes one line.
e972489 to
74d9021
Compare

Context
The issue asks for cardano-cli to support Plutus V4 scripts:
Most of that work was merged with #1453.
It bumped cardano-api to 11.9.0.0, added the
--*-plutus-script-v4reference script flags to the Dijkstra commands, and lethash scriptread Plutus V4 scripts.This PR covers the rest of the issue and builds on #1408.
hash script,transaction policyid --script-fileandaddress buildwith--payment-script-fileor--stake-script-filenow read scripts through one helper,readAnyScriptHash.It decodes the script in cardano-api's newest era (
maxBound :: Some Era) and returns only the era-independent script hash.So
transaction policyidandaddress buildnow accept Plutus V4 scripts.They also accept simple scripts with a
guard, which used to stop them withtoAllegraTimelock: RequireGuard is only supported from the Dijkstra era onwards.They used to fail with "Plutus language PlutusScriptV4 is not supported in the Conway era", as
hash scriptdid before #1453.A transaction output with a reference script in a Plutus language that the era does not support now fails with cardano-api's
TxOutputReferenceScriptLanguageNotSupportedInEraerror.Before this change,
readRefScriptdropped such a script from the output without telling the user, for example a Plutus V4 script in a Conway transaction.cardano-api's own check,
validateTxOutsReferenceScripts, is not exported, soreadRefScriptrepeats it withtoScriptInEra.The PR also removes two Conway hardcodes:
CARDANO_ERA=dijkstracrashed every command,--versionincluded, with "Unknown era: dijkstra". The variable is now parsed with cardano-api's era enumeration and names, so every era cardano-api knows is accepted in any letter case, and an unknown value stops the command with an error that lists the valid eras.latestcommand group and the top-levelnodeandquerygroups now use aMainnetEraalias, which is still Conway. At the hard fork only the alias changes, and thelatesthelp text takes the era name from it.Closes #1448.
One gap is outside cardano-cli: a Plutus V4 auxiliary script is dropped when a Dijkstra transaction is read back, until a cardano-ledger-dijkstra release with this change reaches CHaP:
eraMaxLanguagetoPlutusV4, fix tests cardano-ledger#6109How to trust this PR
The Plutus V4 changes have golden tests:
dijkstra transaction build-rawtakes the V4 script file as a direct witness for all six script purposes, anddebug transaction viewshowsplutus version: PlutusV4for it.hash scriptandtransaction policyidgive the same hash for the V4 script.address buildworks with a V4 payment script and with a V4 stake script.conway transaction build-rawwith a V4 reference script fails with the new error.The fixture
v4-always-succeeds.plutusis an always-succeeds validator; compiled againstPlutusLedgerApi.V4it has the same bytes as the V3 version.For V1, V2, V3 and native scripts,
transaction policyidandaddress buildgive the same output as before.The
CARDANO_ERAfix and the guard-script case were checked by hand, before and after the change, and have no automated tests.MainnetErachanges no output, and all help goldens are unchanged.Checklist
.changes/